#ifndef GLWINDOW_H
#define GLWINDOW_H
#include <QtGui>
#include <QOpenGLFunctions_4_3_Core>
#include <QGLWidget>
#include "ksprite.h"

class GLWindow : public QWindow,
        protected QOpenGLFunctions_4_3_Core
{
public:
    GLWindow(QWindow *parent = Q_NULLPTR);
    ~GLWindow();
protected:
   void exposeEvent( QExposeEvent* pEvent );
   void InitGL( void );                    // 额外OpenGL的初始化
   void RenderGL( void );                  // OpenGL渲染相关
   void ResizeGL( int width, int height ); // 窗口大小改变时该如何应对
   void ReleaseGL(void);

private:
   void LoadShaders(const QString& vertShader, const QString& fragShader );
   void loadTextures();
   void initVertexData();
   GLuint readImage(const char *filename);
   void addSprite(KSprite *sprite);

   GLfloat viewportWidth = 1000, viewportHeight = 500;
   GLfloat imgWidth, imgHeight;
   GLfloat designWidth = 2400, designHeight = 1200;

   KSprite *sprite;

   QVector<KSprite*> sprites;

   QOpenGLContext* m_pContext;
};

#endif // GLWINDOW_H
